<template>
  <div>
    <!-- profile pc端 -->
    <div class="user_profile_pc">
      <div class="profile" key="profile">
        <div class="profile_top" style="text-align: left">
          {{ $t("profile.Accounts") }}
        </div>
        <div class="centent">
          <span class="centent_span01">{{ $t("profile.Balance2") }}</span>
          <br />
          <span class="centent_span02">￥{{userinfo.pendingAmount}}</span> <br />
          <span class="centent_span03"
            >{{ $t("profile.paypal")
            }}<a @click="btnHere" style="color: #ff5900"
              >{{ $t("profile.here") }} <span> > </span></a
            ></span
          >
        </div>

        <div class="center_bottom">
          <div class="profile-items-title">
            {{ $t("profile.Favorite") }}
            <i class="add-icon" @click="tranChange"
              ><div class="add01"></div>
              <div :class="{ add03: isShowClass }" class="add02"></div>
            </i>
          </div>
          <p class="profile_pc_favoriteBox-text , profile_pc_favoriteBox-text2">
            {{ $t("profile.addlike") }}<i class="heart_icon"></i>
            {{ $t("profile.addlike01") }}
          </p>

          <transition name="picker">
            <div
              v-if="show"
              class="profile_pc_favoriteBox-text , profile_pc_favoriteBox-text2 , maxHeight"
            >
              <div
                v-show="showAll"
                v-for="item in goodsCollectionList"
                :key="item.collect_id"
                class="collectionItem itemBox-animate"
                @click="goDetail(item)"
              >
                <img class="collectionItem_img" :src="item.image" alt="" />
                <p class="collectionItem_title">{{ item.title }}</p>
                <span class="collectionItem_price">
                   ￥0
                  <span class="collectionItem_grey">￥{{item.price}}</span></span
                >
              </div> 
              <div
                v-show="showAll"
                class="commonPage_pageComponent_1T1f7"
                style="background: white; margin-top: 20px"
              >
                <img
                  src="../../assets/images/375_09.png"
                  class="commonPage_preIcon_1KM76"
                  @click="prevPage"
                />
                <div class="commonPage_currentBox_SOGvT" style="width: 51px;
    margin: 0 12px;">
                  <el-input v-model="shopPage"></el-input>
                </div>
                <img
                  src="../../assets/images/375_11.png"
                  class="commonPage_nextIcon_2Lq2N"
                  @click="nextPage"
                />
              </div>
            </div>
          </transition>
        </div>
      </div>
    </div>

    <!-- profile 移动端 -->
    <div class="user_profile_iphone">
      <div class="mainPage_mb_content">
        <div class="profile" pagecurrentscrolltop="0">
          <div class="main">
            <div class="profile-content">
              <section class="profile-account">
                <div class="profile-account-title">Balance Accounts</div>
                <div class="profile-account-text">
                  <p class="profile-text-title">Cash Back Balance</p>
                  <p class="text-color">￥{{userinfo.pendingAmount}}</p>
                  <p class="common-p-color">
                    Take to your paypal account
                    <span class="common-span-color"> here &gt;</span>
                  </p>
                </div>
                <div class="profile-account-text">
                  <p class="profile-text-title">Points Balance</p>
                  <p class="text-color">{{userinfo.pendingAmount}}</p>
                  <p class="common-p-color">
                    Learn how to earn reward points
                    <span class="common-span-color"> here &gt;</span>
                  </p>
                </div>
              </section>
              <section class="profile-items">
                <div class="profile-favorite">
                  <div class="profile-items-title">
                    Favorite Items <i @click="addIconChange" class="add-icon"><span  class="add-icon-1" ></span><span class="add-icon-2" :class="{'add-icon-3': icon}"></span></i>
                  </div>
                  <div class="profile-items-text">
                    <p>
                      To wait until another time to buy some of the items in the
                      catogories, click<i
                        class="profile_img01"
                        src="/common/static/index/img2/heartIcon.68fed58b.png"
                        width="15"
                        height="15"
                        alt=""
                        style="display: inline-block; vertical-align: -0.15rem"
                      >
                      </i
                      >,and the item will be added to your favorites here.
                    </p>
                  </div>
                </div>
              </section>
              <div v-show="icon" class="swiper-box">
                <div class="swiper-container">
                  <ul class="swiper-wrapper">
                    <li v-for="item in goodsCollectionList" :key="item.id"   class="swiper-slide" @click="goDetail(item)">
                      <img  :src="item.image" class="item-img">
                        <p  class="item-priceBox">
                          <span  class="item-price">￥0</span>
                          <span  class="item-price--throght">￥{{item.price}}</span>
                        </p>
                    </li>
                    <li @click="collectionListChange"  class="swiper-slide , profile-coupons" >
                      <div  class="profile-coupons-title"> View All <br > Coupons </div>
                      <img class="PROFILE-img" data-v-262a1df6="" src="" width="25" height="26" style="pointer-events: none; width: 25px; height: 26px;">
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper"; 
export default {
  name: "profile",
  data() {
    return {
      icon:false,
      show: false,  
      isShowClass: false,
      icons:'90deg',
      showAll: false,
      goodsCollectionList:[],
      shopPage:1,
      totalPage:''
      
    };
  },
  created(){
      this.$axios({
        url:'/user/siteUserFavoriteRecord/siteUserFavoriteRecords',
        method:'get',
        params:{
          current: this.shopPage,
          size: 5,
          descs: 'created_time',
          countryCode: 'US',
          supportedChannel: 3,
        }
      }).then(res=>{
        console.log(res)
        this.goodsCollectionList=res.data.records
        this.totalPage=res.data.total
        if(this.goodsCollectionList.length>0){
          this.showAll=true;
          this.show=true;
          this.icon=true
        }
      })
  },
  mounted() {
    var mySwiper = new Swiper(".swiper-container", {
      loopAdditionSlides: 10,
      circular: true,
      slidesPerView:'auto', 
      autoplay: 2000,
      autoplayDisableOnInteraction: false,
      paginationClickable: true,
      observer: true, //修改swiper自己或子元素时，自动初始化swiper
      observeParents: false, //修改swiper的父元素时，自动初始化swiper
      // slidesPerView: 2, // 一次显示4张图片
      loopedSlides: 4,
    });
  },
  computed:{
	userinfo(){
		return this.$store.state.userinfo
	}  
  },
  methods: {
    addIconChange(){
      this.icon = !this.icon
      console.log(this.icon);
      this.icons = '0deg'
    },
    btnHere() {
      this.$router.push("/balance");
    },
    collectionListChange(){
      this.$router.push('/collectionListChange')
    },
    goDetail(item1){
      console.log(item1)
      let goods_id=item1.reviewTaskId
      this.$router.push({path:'/shopdetail',query:{id:goods_id,current:this.shopPage}})
    },
    tranChange() {
      this.isShowClass = !this.isShowClass;
      this.show = !this.show;
      console.log("s");
      console.log(this.showAll);
      if ((this.showAll = false)) {
        this.showAll = !this.showAll;
      } else {
        setTimeout(() => {
          this.showAll = !this.showAll;
        }, 250);
      }
    },
    prevPage() {
				if (this.shopPage > 1) {
					this.shopPage -= 1;
					this.goodsCollectionList = []
					this.$loading()
					this.$axios({
					url:'/user/siteUserFavoriteRecord/siteUserFavoriteRecords',
					method: "get",
					params:{
          current: this.shopPage,
          size: 5,
          descs: 'created_time',
          countryCode: 'US',
          supportedChannel: 3,
        }
				}).then((res1) => {
             if (res1.data.pages == 0) {
            console.log("获取不到数据");
            this.searchIsShow = true;
          } else {
            this.searchIsShow = false;
          }
					this.$Toastclear()
					console.log(res1)
					this.goodsCollectionList = res1.data.records
					this.totalPage = res1.data.total
				})
				}

			},
			// 下一页
			nextPage() {
				if (this.totalPage >=this.shopPage*5) {
					this.goodsCollectionList = []
					this.shopPage += 1;
					this.$loading()
					this.$axios({
					url:'/user/siteUserFavoriteRecord/siteUserFavoriteRecords',
					method: "get",
					params:{
          current: this.shopPage,
          size: 5,
          descs: 'created_time',
          countryCode: 'US',
          supportedChannel: 3,
        }
				}).then((res3) => {
          
					this.$Toastclear()
						if (this.goodsCollectionList.length) {
							this.showToast('no data', 'データなし')
							this.shopPage += 1;
							return
						}
						this.goodsCollectionList = res3.data.records
				})
				} else {
					this.showToast('There is no next page', '次のページがない')
				}
			}
  },
};
</script>

<style lang = 'scss' scoped>
@media only screen and (max-width: 900px) {
  .user_profile_pc {
    display: none;
    overflow: hidden;
  }
}
@media only screen and (min-width: 900px) {
  .user_profile_iphone {
    display: none;
  }
  html {
    font-size: 30px;
  }
}

/* pc端的样式 */
.user_profile_pc {
  .add-icon {
    vertical-align: middle;
    float: right;
    position: relative;
    width: 1.5rem;
    height: 1.5rem;
    margin-top: 22px;
    overflow: hidden;
    -webkit-transition: 0.5s;
    transition: 0.5s;
    background-color: #ff5900;
    border-radius: 50%;
    color: white;
  }
  .add02 {
    height: 1rem;
    width: 0.15rem;
    background-color: white;
    position: relative;
    left: 13px;
    transform: rotateZ(0deg);
    transition: transform 1s;
  }
  .add03 {
    transition: transform 1s;
    transform: rotateZ(90deg);
  }

  .add01 {
    width: 1rem;
    height: 0.2rem;
    background-color: white;
    position: relative;
    top: 12px;
    left: 5px;
  }

  .profile { 
    background-color: rgb(245, 245, 245);
    margin-left: 20px;
    margin-right: 20px;
  }
  .profile_top {
    font-size: 22px;
    color: #fff;
    padding: 10px 0 10px 20px;
    background-color: #ff5900;
    border-bottom: 1px solid #efefef;
    text-align: center;
  }
  .centent {
    /* display: flex; */
    background: #fff;
    padding: 20px;
    padding-top: 40px;
    font-size: 22px;
    text-align: center;
  }
  .centent_span02 {
    color: #ffaf52;
    font-family: Roboto-Bold;
    display: inline-block;
    margin: 10px 0;
    font-size: 26px;
    font-weight: 800;
  }
  .centent_span03 {
    font-size: 14px;
    font-weight: 400;
  }
  .center_bottom {
    margin-top: 20px;
    background: #fff;
    margin-bottom: 20px;
  }
  .profile-items-title {
    height: 66px;
    line-height: 66px;
    font-size: 22px;
    padding: 0 20px;
    color: #ff5900;
    text-align: left;
  }
  .profile_pc_favoriteBox-text {
    padding: 20px 50px;
    border-top: 1px solid #ccc;
    text-align: left;
  }
  .profile_pc_favoriteBox-text2 {
    color: #575556;
    font-size: 16px;
    font-weight: 400;
    font-family: Roboto-Regular;
  }
  .collectionItem {
    width: 210px;
    height: 220px;
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 10px;
    box-sizing: border-box;
    display: inline-block;
    margin: 0 5px;
  }
  .collectionItem_img {
    border: 0;
    height: 125px;
    width: 125px;
    display: block;
    margin: 0 auto;
    max-width: 100%;
  }
  .collectionItem_title {
    font-size: 12px;
    color: #858585;
    height: 26px;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    padding-top: 5px;
  }
  .collectionItem_price {
    font-size: 24px;
    color: #ff9616;
    font-family: Roboto-Bold;
    vertical-align: middle;
  }

  .collectionItem_grey {
    text-decoration: line-through;
    color: #ccc;
    display: inline-block;
    font-family: none;
    vertical-align: top;
    margin-left: 4px;
    font-size: 16px;
  }

  .itemBox-animate {
    transition: transform 0.6s cubic-bezier(0.34, 2, 0.6, 1),
      box-shadow 0.2s ease;
  }
  .itemBox-animate:hover {
    box-shadow: 0 12px 17px -7px rgba(0, 0, 0, 0.3);
    transform: translateY(-8px);
  }
  .commonPage_pageComponent_1T1f7 {
    height: 2rem;
    line-height: 2rem;
    width: 100%;
    background: #fff;
    white-space: nowrap;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .commonPage_pageComponent_1T1f7 .commonPage_nextIcon_2Lq2N,
  .commonPage_pageComponent_1T1f7 .commonPage_preIcon_1KM76 {
    height: 2.25rem;
    width: 2.25rem;
    cursor: pointer;
  }
  .commonPage_pageComponent_1T1f7 .commonPage_currentBox_SOGvT {
    display: inline-block;
    max-width: 70%;
    /* overflow-x: scroll; */
  }
  .commonPage_pageComponent_1T1f7
    .commonPage_currentBox_SOGvT
    .commonPage_pageText_3a5JB {
    font-size: 1.2rem;
    display: inline-block;
    margin: 0 0.45rem;
    cursor: pointer;
  }
  .maxHeight {
    transition: height 2s;
    overflow: hidden;
  }

  .heart_icon {
    display: inline-block;
    vertical-align: middle;
    width: 17px;
    height: 17px;
    margin-left: 4px;
    background: url()
      0 0 no-repeat;
  }

  /* 容器 高度进入和离开 的过渡动画 */
  .picker-enter-active,
  .picker-leave-active {
    transition: height 0.25s;
  }
  /* 定义进入过渡的开始状态 和 离开过渡的结束状态 */
  .picker-enter,
  .picker-leave-to {
    height: 0;
  }
  /* 定义进入过渡的结束状态 和 离开过渡的开始状态 */
  .picker-enter-to,
  .picker-leave {
    height: 270px;
  }
}

/* 移动端的样式 */
.mainPage_mb_content {
  background: #f5f5f5;
  padding-bottom: calc(2.15rem + env(safe-area-inset-bottom));
  padding-bottom: calc(2.15rem + constant(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.profile {
  height: auto;
  overflow: auto;
}
.profile .main {
  padding-top: 0.2rem;
  background-color: #f5f5f5;
}
.profile .main .profile-content {
  background: #f7f7f7;
  padding: 0.6rem 0.6rem 1.25rem 0.6rem;
  text-align: left;
}
.profile-account {
  margin-bottom: 0.55rem;
  background: #fff;
}
.profile-account-title {
  background-color: #ff5900;
  color: #fff;
  padding: 0.6rem 2.7rem 0.6rem 0.45rem;
  border-bottom: 0.05rem solid #f2f2f2;
  font-size: 0.9rem;
}
.profile-text-title {
  font-size: 1.1rem;
  color: #000;
  padding: 0.7rem 0 0;
}
.profile .main .profile-content .profile-account .profile-account-title {
  background-color: #ff5900;
  color: #fff;
  padding: 0.6rem 2.7rem 0.6rem 0.45rem;
  border-bottom: 0.05rem solid #f2f2f2;
  font-size: 0.9rem;
}
.profile .main .profile-content .profile-account .profile-account-text {
  border-bottom: 1px solid #f5f5f5;
  padding: 0.2rem 0 0.55rem 0.45rem;
}
.profile
  .main
  .profile-content
  .profile-account
  .profile-account-text
  .text-color {
  color: #ffaf52;
  font-size: 1.7rem;
  padding: 0.6rem 0;
}
.profile
  .main
  .profile-content
  .profile-account
  .profile-account-text
  .common-p-color {
  font-size: 0.7rem;
  color: #757575;
}
.profile
  .main
  .profile-content
  .profile-account
  .profile-account-text
  .common-p-color
  .common-span-color {
  font-size: 0.8rem;
  color: #ff5900;
}

.profile section {
  margin-bottom: 0.55rem;
  background: #fff;
}
.profile
  .main
  .profile-content
  .profile-items
  .profile-favorite
  .profile-items-title {
  padding: 0.55rem 0.45rem 0.45rem 0.45rem;
  border-bottom: 0.05rem solid #f2f2f2;
  font-size: 0.875rem;
  color: #000;
}
.profile
  .main
  .profile-content
  .profile-items
  .profile-favorite
  .profile-items-title
  i.add-icon {
  float: right;
  position: relative;
  width: 1rem;
  height: 1rem;
  overflow: hidden;
  margin-top: 0.25rem;
  -webkit-transition: 0.5s;
  transition: 0.5s;
  background-color: #ff5900;
  border-radius: 50%;
}

.profile
  .main
  .profile-content
  .profile-items
  .profile-favorite
  .profile-items-text {
  padding: 0.5rem 0.55rem 0.55rem 0.45rem;
  color: #595757;
  font-size: 0.7rem;
  line-height: 1rem;
}
.profile_img01 {
  display: inline-block;
  vertical-align: middle;
  width: 17px;
  height: 17px;
  margin-left: 4px;
  background: url()
    0 0 no-repeat;
}
.profile .category-swipe {
  margin-top: 0.7rem;
  text-align: center;
  width: 100%;
  touch-action: none;
  overflow: hidden;
}
.swiper-container {
  margin-left: auto;
  margin-right: auto;
  position: relative;
  overflow: hidden;
  list-style: none;
  padding: 0;
  z-index: 1;
  height: 100%;
}
.swiper-box {
  width: 100%;
  height: 132px;
}
.swiper-slide{
  height: 100%;
  width: 140px!important;
  margin-right: .3rem!important;
  background-color: #fff;
  
}
.swiperr-wrappe {
  width: 100%;
  height: 100%;
}

/* vant */

.my-swipe {
  margin-left: 0.5rem;
}

.userRatingCardPage {
  width: 8rem;
  height: 6.6rem;
  font-size: 0;
  padding: 0 0.2rem;
  box-sizing: border-box;

  .userRatingCardPage-head {
    display: flex;
    align-items: center;
    height: 2rem;

    img {
      width: 2rem;
      height: 2rem;
      border-radius: 50%;
    }

    .userRatingCardPage-head-name {
      font-size: 0.7rem;
      color: #444;
      margin-left: 0.5rem;
    }
  }
}

.userRatingCardPage-content {
  width: 100%;
  height: 7.9rem;
  background: white;
  border-radius: 0.2rem;
  margin-top: 1rem;
  position: relative;
  padding-top: 0.4rem;
  box-sizing: border-box;
  filter: drop-shadow(0 0 0.1rem rgba(0, 0, 0, 0.3));

  .userRatingCardPage-content-text {
    white-space: normal;
    font-size: 0.6rem;
    color: #666;
    overflow-y: scroll;
    padding: 0.4rem;
    padding-top: 0;
    height: 7.5rem;
    box-sizing: border-box;
  }
}

.my-swipe {
  margin: 0px;
}
.van-swipe {
  margin: 0px;
}

.profile .category-swipe .category-list {
  width: 7rem;
  margin: right 3.9em;
  background: #fff;
  touch-action: none;
  z-index: 10000;
}
.item-img{
    height: 4.2rem;
    width: 4.2rem;
    margin-top: .5rem;
    background: grey;
    pointer-events: none;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}
.item-priceBox{
     text-align: left;
    pointer-events: none;
}
.item-price{
  font-size: 1.12rem;
    pointer-events: none;
    font-family: Roboto-Bold;
    color: #ffaf52;
    vertical-align: middle;
    margin-left: .5rem;
}
.item-price--throght{
  font-size: .6rem;
    pointer-events: none;
    text-decoration: line-through;
    color: #ababab;
    margin-left: .25rem;
    word-wrap: break-word;
    word-break: normal;
}
.profile-coupons-title{
    pointer-events: none;
    margin-top: 1.2rem;
    margin-bottom: .5rem;
    color: #ffaf52;
    font-size: .9rem;
    text-align: center;
}
.PROFILE-img{
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}
.add-icon-1{
  width: 0.8rem;
  height: 0.15rem;
  background-color: white;
  z-index: 999;
  display: inline-block;
  position: relative;
  top: -0.28rem;
  left: 0.1rem; 
 
}
.add-icon-2{
  width: 0.8rem;
  height: 0.14rem;
  background-color: white;
  z-index: 999;
  display: inline-block;
  position: absolute;
  top: 0.44rem;
  left: 0.1rem;
  transform: rotateZ(90deg);
  transition: transform 1s;
}
.add-icon-3{
   transform: rotateZ(0deg)!important;
   /* background-color: red; */
}
</style>
